<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    response.setHeader("Cache-Control","no-store");
    response.setHeader("Pragrma","no-cache");
    response.setDateHeader("Expires",0);
%>
<html>
<head>
    <title>书籍列表</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

</head>
<body>

<div class="container">

    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1 style="display: inline-block;">
                    <small>书籍列表 —— 显示所有书籍</small>
                </h1>
               <div style="display: inline-block; float: right;padding-top: 10px" >
                   <span>${sessionScope.loginUser.username},欢迎您</span>
                   <p><a class="btn btn-primary" href="${pageContext.request.contextPath}/user/doLogout" role="button">退出登录</a></p>
               </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4 column">
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增书籍</a>
        </div>
        <div class="col-md-8 column">
            <form action="${pageContext.request.contextPath}/book/queryBook" method="post" style="float: right" class="form-inline">
                <input type="text" name="bookName" class="form-control" value="${bookName}" placeholder="请输入查询条件">
                <input type="submit" value="查询" class="btn btn-primary">
            </form>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>书籍编号</th>
                    <th>书籍名字</th>
                    <th>书籍数量</th>
                    <th>书籍作者</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody>
                <c:forEach var="book" items="${requestScope.get('list2')}">
                    <tr>
                        <td>${book.getBookID()}</td>
                        <td>${book.getBookName()}</td>
                        <td>${book.getBookCounts()}</td>
                        <td>${book.getAuthor().authorName}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.getBookID()}">更改</a> |
                            <a href="${pageContext.request.contextPath}/book/deleteBook/${book.getBookID()}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <nav aria-label="Page navigation">
        <ul class="pagination pagination-lg">
            <c:forEach var="i" items="${requestScope.get('pageArray2')}">
            <li><a href="${pageContext.request.contextPath}/book/pageLikeController?pageNum2=${i}">${i}</a></li>
            </c:forEach>
        </ul>
    </nav>
</div>